using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using T2.WebSecurity.Data.Entities.Interfaces;
using T2.WebSecurity.Data.Entities;
using T2.WebSecurity.Business.Entities.Interfaces;
using T2.WebSecurity.Business.Entities;
using T2.WebSecurity.Business.Entities.Search.Interfaces;
using T2.WebSecurity.Data.Entities.Search.Interfaces;
using T2.WebSecurity.Data.Entities.Search;


//--Change Management Control - Membership Business Translator  --**********************
//--Created By: trooks
//--Description: Membership Translator
//--Created Date: 03/07/2013 10:48:39
//--*************************************************************

namespace T2.WebSecurity.Business.Translators
{
	public static class MembershipTranslator 
	{
		public static IMembership TranslateToDataLayer(IMembership_biz _translateFrom)
        {
            IMembership temp = new Membership();

		
			if(_translateFrom != null)
			{
			temp.Action = _translateFrom.Action;
			temp.Caller = _translateFrom.Caller;
			temp.Role = _translateFrom.Role;
			temp.PageSize = _translateFrom.PageSize;
			temp.PageNumber = _translateFrom.PageNumber;
			temp.SortColumn = _translateFrom.SortColumn;
			temp.SortType = _translateFrom.SortType;
			temp.TotalRows = _translateFrom.TotalRows;
			temp.MembershipID = _translateFrom.MembershipID;
			temp.ConfirmationToken = _translateFrom.ConfirmationToken;
			temp.IsConfirmed = _translateFrom.IsConfirmed;
			temp.LastPasswordFailureDate = _translateFrom.LastPasswordFailureDate;
			temp.PasswordFailuresSinceLastSuccess = _translateFrom.PasswordFailuresSinceLastSuccess;
			temp.Password = _translateFrom.Password;
			temp.PasswordChangedDate = _translateFrom.PasswordChangedDate;
			temp.PasswordSalt = _translateFrom.PasswordSalt;
			temp.PasswordVerificationToken = _translateFrom.PasswordVerificationToken;
			temp.PasswordVerificationTokenExpirationDate = _translateFrom.PasswordVerificationTokenExpirationDate;
			temp.TS = _translateFrom.TS;
			temp.CreatedBy = _translateFrom.CreatedBy;
			temp.CreatedDt = _translateFrom.CreatedDt;
			temp.ModifiedBy = _translateFrom.ModifiedBy;
			temp.ModifiedDt = _translateFrom.ModifiedDt;
			temp.EmailAccount = _translateFrom.EmailAccount;
			temp.PasswordAnswer = _translateFrom.PasswordAnswer;
			temp.LastLoginDate = _translateFrom.LastLoginDate;
			temp.LastLockoutDate = _translateFrom.LastLockoutDate;
			temp.UserId = _translateFrom.UserId;
			temp.PasswordQuestionID = _translateFrom.PasswordQuestionID;
			}
            return temp;
        }
		
		public static IMembershipSearch TranslateSearchToDataLayer(IMembershipSearch_biz _translateFrom)
        {
            IMembershipSearch temp = new MembershipSearch();
		
			if(_translateFrom != null)
			{
			temp.Action = _translateFrom.Action;
			temp.Caller = _translateFrom.Caller;
			temp.Role = _translateFrom.Role;
			temp.PageSize = _translateFrom.PageSize;
			temp.PageNumber = _translateFrom.PageNumber;
			temp.SortColumn = _translateFrom.SortColumn;
			temp.SortType = _translateFrom.SortType;
			temp.TotalRows = _translateFrom.TotalRows;
			temp.ConfirmationToken = _translateFrom.ConfirmationToken;
			//temp.Beg_LastPasswordFailureDate = _translateFrom.Beg_LastPasswordFailureDate;
                if(_translateFrom.Beg_LastPasswordFailureDate !=DateTime.MinValue)
                    temp.Beg_LastPasswordFailureDate = _translateFrom.Beg_LastPasswordFailureDate;
                else
                    temp.Beg_LastPasswordFailureDate = Convert.ToDateTime(@"01/01/1800");
			//temp.End_LastPasswordFailureDate = _translateFrom.End_LastPasswordFailureDate;
                if (_translateFrom.End_LastPasswordFailureDate != DateTime.MinValue)
                    temp.End_LastPasswordFailureDate = _translateFrom.End_LastPasswordFailureDate;
                else
                    temp.End_LastPasswordFailureDate = Convert.ToDateTime(@"12/31/2032");
			temp.Beg_PasswordFailuresSinceLastSuccess = _translateFrom.Beg_PasswordFailuresSinceLastSuccess;    
			temp.End_PasswordFailuresSinceLastSuccess = _translateFrom.End_PasswordFailuresSinceLastSuccess;
			temp.Password = _translateFrom.Password;
			//temp.Beg_PasswordChangedDate = _translateFrom.Beg_PasswordChangedDate;
            if (_translateFrom.Beg_PasswordChangedDate != DateTime.MinValue)
                    temp.Beg_PasswordChangedDate = _translateFrom.Beg_PasswordChangedDate;
                else
                temp.Beg_PasswordChangedDate = Convert.ToDateTime(@"01/01/1800");
			//temp.End_PasswordChangedDate = _translateFrom.End_PasswordChangedDate;
            if (_translateFrom.End_PasswordChangedDate != DateTime.MinValue)
                    temp.End_PasswordChangedDate = _translateFrom.End_PasswordChangedDate;
                else
                temp.End_PasswordChangedDate = Convert.ToDateTime(@"12/31/2032");
			temp.PasswordSalt = _translateFrom.PasswordSalt;
			temp.PasswordVerificationToken = _translateFrom.PasswordVerificationToken;
			//temp.Beg_PasswordVerificationTokenExpirationDate = _translateFrom.Beg_PasswordVerificationTokenExpirationDate;
            if (_translateFrom.Beg_PasswordVerificationTokenExpirationDate != DateTime.MinValue)
                    temp.Beg_PasswordVerificationTokenExpirationDate = _translateFrom.Beg_PasswordVerificationTokenExpirationDate;
                else
                temp.Beg_PasswordVerificationTokenExpirationDate = Convert.ToDateTime(@"01/01/1800");
			//temp.End_PasswordVerificationTokenExpirationDate = _translateFrom.End_PasswordVerificationTokenExpirationDate;
            if (_translateFrom.End_PasswordVerificationTokenExpirationDate != DateTime.MinValue)
                temp.End_PasswordVerificationTokenExpirationDate = _translateFrom.End_PasswordVerificationTokenExpirationDate;
            else
                temp.End_PasswordVerificationTokenExpirationDate = Convert.ToDateTime(@"12/31/2032");
			temp.EmailAccount = _translateFrom.EmailAccount;
			temp.PasswordAnswer = _translateFrom.PasswordAnswer;
			}
            return temp;
        }

        public static IMembership_biz TranslateFromDataLayer(IMembership _translateFrom)
        {
            IMembership_biz temp = new Membership_biz();
			if(_translateFrom != null)
			{
			temp.Action = _translateFrom.Action;
			temp.Caller = _translateFrom.Caller;
			temp.Role = _translateFrom.Role;
			temp.PageSize = _translateFrom.PageSize;
			temp.PageNumber = _translateFrom.PageNumber;
			temp.SortColumn = _translateFrom.SortColumn;
			temp.SortType = _translateFrom.SortType;
			temp.TotalRows = _translateFrom.TotalRows;
			temp.MembershipID = _translateFrom.MembershipID;
			temp.ConfirmationToken = _translateFrom.ConfirmationToken;
			temp.IsConfirmed = _translateFrom.IsConfirmed;
			temp.LastPasswordFailureDate = _translateFrom.LastPasswordFailureDate;
			temp.PasswordFailuresSinceLastSuccess = _translateFrom.PasswordFailuresSinceLastSuccess;
			temp.Password = _translateFrom.Password;
			temp.PasswordChangedDate = _translateFrom.PasswordChangedDate;
			temp.PasswordSalt = _translateFrom.PasswordSalt;
			temp.PasswordVerificationToken = _translateFrom.PasswordVerificationToken;
			temp.PasswordVerificationTokenExpirationDate = _translateFrom.PasswordVerificationTokenExpirationDate;
			temp.TS = _translateFrom.TS;
			temp.CreatedBy = _translateFrom.CreatedBy;
			temp.CreatedDt = _translateFrom.CreatedDt;
			temp.ModifiedBy = _translateFrom.ModifiedBy;
			temp.ModifiedDt = _translateFrom.ModifiedDt;
			temp.EmailAccount = _translateFrom.EmailAccount;
			temp.PasswordAnswer = _translateFrom.PasswordAnswer;
			temp.LastLoginDate = _translateFrom.LastLoginDate;
			temp.LastLockoutDate = _translateFrom.LastLockoutDate;
			temp.UserId = _translateFrom.UserId;
			temp.PasswordQuestionID = _translateFrom.PasswordQuestionID;
			}
            return temp;
        
        }
	
	}
	
}
